//
//  XJPersonSetCell.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/3.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJPersonSetCell.h"

@implementation XJPersonSetCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString * cellID = @"XJPersonSetCell";
    XJPersonSetCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell==nil) {
        cell = [[XJPersonSetCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.backgroundColor = WHITE_COLOR;
    }
    return cell;
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubviews];
    }
    return self;
    
}

- (UILabel *)xjps_titleLab{
    if (!_xjps_titleLab) {
        UILabel * xjps_titleLab = [UILabel new];
        self.xjps_titleLab = xjps_titleLab;
        [self.contentView addSubview:xjps_titleLab];
    }
    return _xjps_titleLab;
}

- (UIImageView *)xjps_indicator{
    if (!_xjps_indicator) {
        UIImageView * xjps_indicator = [UIImageView new];
        self.xjps_indicator = xjps_indicator;
        [self.contentView addSubview:xjps_indicator];
    }
    return _xjps_indicator;
    
}

- (UILabel *)xjps_detailLab{
    
    if (!_xjps_detailLab) {
        UILabel * xjps_detailLab = [UILabel new];
        self.xjps_detailLab = xjps_detailLab;
        [self.contentView addSubview:xjps_detailLab];
    }
    return _xjps_detailLab;
}

- (void)setupSubviews{
    
    self.xjps_titleLab.font = XJFONTSET_R(14);
    self.xjps_titleLab.textColor = XJCOLOR_RGB(17, 17, 17);
    
    self.xjps_indicator.image = [UIImage imageNamed:@"direction_right_black"];
    self.xjps_indicator.sd_layout
    .centerYEqualToView(self.contentView)
    .rightSpaceToView(self.contentView, ADAPTWidth(20))
    .widthIs(12)
    .heightIs(12);
    
    self.xjps_detailLab.font = XJFONTSET_R(14);
    self.xjps_detailLab.textColor = XJCOLOR_RGB(17, 17, 17);
}

- (void)setShowIndicator:(BOOL)showIndicator{
    _showIndicator = showIndicator;
}

- (void)setTitleStr:(NSString *)titleStr{
    _titleStr = titleStr;
    self.xjps_titleLab.text = titleStr;
    
    CGFloat xjps_titleLabW = [UILabel labelWithLabel:self.xjps_titleLab getWidthWithTitle:titleStr font:self.xjps_titleLab.font];
    CGFloat xjps_titleLabH = [UILabel labelWithLabel:self.xjps_titleLab getHeightByWidth:xjps_titleLabW title:titleStr font:self.xjps_titleLab.font];
    self.xjps_titleLab.sd_layout
    .leftSpaceToView(self.contentView, ADAPTWidth(20))
    .centerYEqualToView(self.contentView)
    .widthIs(xjps_titleLabW)
    .heightIs(xjps_titleLabH);
    
}

- (void)setDataStr:(NSString *)dataStr{
    _dataStr = dataStr;
    self.xjps_detailLab.text = dataStr;
    
    CGFloat xjps_detailLabW = [UILabel labelWithLabel:self.xjps_detailLab getWidthWithTitle:dataStr font:self.xjps_detailLab.font];
    CGFloat xjps_detailLabH = [UILabel labelWithLabel:self.xjps_detailLab getHeightByWidth:xjps_detailLabW title:dataStr font:self.xjps_detailLab.font];
    self.xjps_detailLab.sd_layout
    .rightSpaceToView(_showIndicator?self.xjps_indicator:self.contentView, _showIndicator?ADAPTWidth(6): ADAPTWidth(20))
    .centerYEqualToView(self.contentView)
    .widthIs(xjps_detailLabW)
    .heightIs(xjps_detailLabH);
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
